/**
 * 
 */
package com.mc.yingshi;

import java.io.IOException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import okhttp3.Call;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

/**
 * @author w.weizhen
 *
 */
public class Address {
    private static String accessToken="at.bgpje2fq19worw2p6znsortgduibkf3a-2vdixl1jwn-0k2g1i9-zeyd5py7a";
    private static String liveAddressGet="https://open.ys7.com/api/lapp/v2/live/address/get";//获取播放地址
    /**
     * @param args
     */
    public static void main(String[] args) {
        liveAddressGet();//获取播放地址
        
    }
    private static void liveAddressGet(){
        OkHttpClient okHttpClient = new OkHttpClient();
        RequestBody requestBody = new FormBody.Builder()
            .add("accessToken", accessToken)
            .add("deviceSerial", "D73973828")//直播源，例如427734222，均采用英文符号，限制50个
            .add("channelNo", "1")//通道号,，非必选，默认为1
            .add("protocol", "2")//流播放协议，1-ezopen、2-hls、3-rtmp、4-flv，默认为1    
            .add("quality", "2")//视频清晰度，1-高清（主码流）、2-流畅（子码流）  
            //.add("supportH265", "0")//是否要求播放视频为H265编码格式,1表示需要，0表示不要求  
            .build();
        Request request = new Request.Builder()
            .url(liveAddressGet)
            .post(requestBody)
            .build();
        Call call = okHttpClient.newCall(request);
        try {
            Response response = call.execute();
            String responseBody = response.body().string();
            System.out.println(responseBody);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
